import OceanComponent from './OceanComponent';
import ODrawer from '../../components/Drawer.vue';
import { DrawerProps } from 'naive-ui';
import Buttons, { TButtonProps } from './Button';

class Drawer extends OceanComponent<DrawerProps & DrawerPropsExt> {
  title: string;
  buttons: Buttons = new Buttons();
  componentAttrs: any;
  component: __VueComponent;
  constructor(title: string, component?: __VueComponent, attrs?: DrawerProps) {
    super(ODrawer, attrs, {
      show: false,
      displayDirective: 'if',
      'on-update:show': v => (this.attrs.show = v),
      size: 'small'
    });
    this.title = title;
    this.component = typeof component == 'function' ? component : () => component;
  }
  open(componentAttrs?): void {
    this.componentAttrs = componentAttrs;
    this.attrs.show = true;
  }
  close(): void {
    this.attrs.show = false;
  }
  button(name: string, props?: TButtonProps) {
    return this.buttons.button(name, props);
  }
  setTitle(title: string) {
    this.title = title;
    return this;
  }
}
export default Drawer;
